<include file="Public/header" title="用户列表" />
<div id="page-wrapper">
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="/admin.php">首页</a>
        </li>
        <li class="breadcrumb-item active">用户管理</li>
      </ol>
    <div class="row">
        <div class="col-lg-12">
            
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <a href="{:U('member/add')}" class="btn btn-success">添加用户</a>
        </div>
        <div class="col-md-6">
            <form action="{:U('member/index')}" method="post">
                <div class="form-group input-group">
                    <input type="text" class="form-control" name="key" placeholder="输入用户名或者邮箱关键词搜索">
                    <span class="input-group-btn">
                      <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    

    <table class="table table-hover table-striped">
        <thead>
            <tr>
                <td>编号</td>
                <td>手机号</td>
                <td>注册时间</td>
                <td>上次登陆</td>
                <td>登陆IP</td>
                <td>类型</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
        <foreach name="member" item="v">
            <tr>
                <td>{$v.id}</td>
                <td>{$v.phone} <if condition="$v.type eq 1"> <span class="label label-success" onclick='show_card({$v.id})'>预览</span></if></td>
                <td>{$v.create_at|date="Y/m/d H:i:s",###}</td>
                <td>{$v.update_at|date="Y/m/d H:i:s",###}</td>
                <td>{$v.login_ip}</td>
                <td>
                    <if condition="$v.type eq 1"> <span class="label label-success">会员</span>
                    <elseif condition="$v.type eq 2"/><span class="label label-danger">管理员[{$v.username}]</span>
                    </if>
                </td> 
                <td><if condition="$v.status eq 1">正常<else/><span style="color:red">禁用</span></if></td>
                <if condition="$v.status eq 1">	
                	<td><a href="{:U('member/update?id=')}{$v.id}">编辑</a> | <a href="{:U('member/delete_1?id=')}{$v.id}" style="color:red;">禁用</a> | <a href='javascript:del({$v.id})'>删除</a></td>
            	<else/>
            		<td><a href="{:U('member/update?id=')}{$v.id}">编辑</a> | <a href="{:U('member/delete_1?id=')}{$v.id}" style="color:#50AD1E;">启用</a> | <a href='javascript:del({$v.id})'>删除</a></td>
            	</if>
            </tr>
        </foreach>
        </tbody>
    </table>
</div>
<style>
  .layui-layer-shade{background:rgba(0,0,0,0.6) !important}
</style>
<include file="Public/footer" />
<script>
   function del(id){
      if(confirm('确定要删除会员？')){
          $.ajax({
             url:'{:U("member/del_m")}',
             data:{id:id},
             type:'POST',
             success:function(data){
                if(data == 1){
                    alert('删除成功!');
                    location.reload();
                }else{
                    alert('删除失败，请稍后重试!');
                }
             }
          })
      }
   }
   
   function show_card(id){
      layer.open({
          type: 2,
          title: '名片预览',
          shadeClose: true,
          shade: true,
          maxmin: false, 
          area: ['375px', '667px'],
          content: '/index.php?m=&c=card&a=preview&userid='+id
        });
   }
</script>